<?php
/*
	用户端公共文件，访问用户端时默认加载
*/
defined('BY_JYA') or exit('error');
//扫码进入的
if($_RQ['fromuser'] && $_RQ['action']=='team.myhome'){
	$this->session('sao_fromuser',$_RQ['fromuser']);
}
$return['ischecklogin']=$this->model('member')->checklogin();
$return['team_tiaojians']=$this->team_tiaojians;
if($_RQ['action']!='team.myhome'){
if($_RQ['is_access'] && $_RQ['action']!='team.apply' && $_RQ['action'] !='team.myshop' && $_RQ['action'] !='team.info'){
	$member=$this->model('team')->checkmember('',true);
}elseif($_RQ['action']!='team.apply' && $_RQ['action'] !='team.myshop'){
	$member=$this->model('team')->checkmember('',false);
}
if($_RQ['is_access'] && (!$member['is_agent'] || $member['stop']) && $_RQ['action']!='team.apply' && $_RQ['action'] !='team.myshop'){
	//还不是分销商，跳转申请页
	$return['applystatus']=$this->getcolumn('member',array('mid'=>$_SESSION['uid']),'apply_status');
	$applyres=$this->model('team')->checkmember('',false);
	$return['desc']=$applyres['desc'];
	$return['now']=$applyres['now'];
	$return['limit']=$applyres['limit'];
	$return['unit']=$applyres['unit'];
	$return['can_apply']=$applyres['can_apply'];
	$return['become_goods']=$applyres['become_goods'];
	$return['member']=$member;
	if($member['agent_id']){
		$return['agent']=model('core/member')->detail($member['agent_id'],array('nickname','avatar'));
		$return['agent_name']=$return['agent']['nickname'];
	}
	$setting=$this->plugin_setting('teampage');
	set_html('title',$setting['tcenter']);
	$return['setting']=$setting;
	$return['teamsetting']=$this->teamsetting;
	$return['setapply']=$this->plugin_setting('teamapply');
	$return['item']=model('core/member')->detail($_SESSION['uid'],array('nickname','avatar','realname','mobile','wechat'));
	$return['htmls']=$this->template_url('team/apply');
	exi($return);
}
}

